<?php

/**
 * Role models 
 * 
 * Role models in console
 *
 * PHP Version: 1.2.3
 * 
 * @author Johari <joharijumali@gmail.com>
 */

/**
 * Class Role
 * 
 * Class Role in console models
 *
 * @author Johari <joharijumali@gmail.com>
 */

class Console_Role extends Eloquent
{

	public static $timestamps = true;
	public static $table = 'sys_user_role';
	public static $key = 'sur_id';
	
	/**
     * Function user
	 *
	 * @return user.
     */
	public function user()
	{
		return $this->belongs_to('Console_User');
	}
	
	/**
     * Function arrayRoles
	 *
	 * @return arrayRoles.
     */
	public static function arrayRoles()
	{
		$rolelist = Console_Role::all();

		$arrayRole = array('Sila Pilih');

		foreach ($rolelist as $value) {
			if (Auth::check() && Auth::user()->sur_id != 1 &&  $value->sur_id != 1) {
				$arrayRole[$value->sur_id] = $value->sur_name;
			} else {
				$arrayRole[$value->sur_id] = $value->sur_name;
			}
		}

		return $arrayRole;
	}

}

?>